var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, o) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var o in e)
              Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          })(e, o);
      };
      return function (e, o) {
        function n() {
          this.constructor = e;
        }
        if ("function" != typeof o && null !== o)
          throw new TypeError(
            "Class extends value " + String(o) + " is not a constructor or null"
          );
        t(e, o),
          (e.prototype =
            null === o
              ? Object.create(o)
              : ((n.prototype = o.prototype), new n()));
      };
    })(),
  Ajax = (function (t) {
    function e(e) {
      var o = t.call(this) || this;
      e && (o.caller = e), (o.headers = []);
      var n = laya.net.LocalStorage.getItem("userId");
      n && o.headers.push("userId", n);
      var s = laya.net.LocalStorage.getItem("accessToken");
      return (
        s && o.headers.push("token", s),
        o.headers.push("key", Utils.accessString()),
        o
      );
    }
    return (
      __extends(e, t),
      (e.prototype.init = function () {
        this.onLoaded(),
          (this.xhr = new Laya.HttpRequest()),
          null == this.success && (this.success = this.onComplete),
          null == this.fail && (this.fail = this.onError),
          this.xhr.once(Laya.Event.COMPLETE, this.caller, this.success),
          this.xhr.once(Laya.Event.ERROR, this.caller, this.fail);
      }),
      (e.prototype.get = function (t, o) {
        this.init();
        o && (t = t + "?" + ("string" == typeof o ? o : e.formData(o))),
          this.xhr.send(t, null, "get", "json", this.headers);
      }),
      (e.prototype.post = function (t, e) {
        this.init(),
          this.headers.push("Content-Type"),
          this.headers.push("application/json"),
          this.xhr.send(t, JSON.stringify(e), "post", "json", this.headers);
      }),
      (e.prototype.onLoaded = function () {}),
      (e.prototype.postForm = function (t, o) {
        this.init();
        var n;
        (n = "string" == typeof o ? o : e.formData(o)),
          this.headers.push("Content-Type"),
          this.headers.push("application/x-www-form-urlencoded"),
          this.xhr.send(t, n, "post", "json", this.headers),
          this.onLoaded();
      }),
      (e.prototype.onError = function (t) {
        console.log("onError" + t), ToastView.toastView("网络异常，请重试");
      }),
      (e.prototype.onComplete = function (t) {
        console.log("onComplete" + t);
      }),
      (e.formData = function (t) {
        for (var e, o = Object.keys(t), n = [], s = 0; s < o.length; s++)
          (e = o[s]), n.push(e + "=" + t[e]);
        return n.join("&");
      }),
      (e.prototype.access = function () {}),
      e
    );
  })(Laya.HttpRequest),
  Result = (function () {
    return function () {};
  })();
